<template>
  <a-drawer :open="visible" title="内部费用单详情" @close="onClose">
    <template #closeIcon>
      <div class="express-bar"></div>
      <div class="express-btn">
        <CloseCircleOutlined :size="32" @click="onClose" />
      </div>
    </template>
    <a-card size="small" title="基本信息">
      <a-descriptions size="small" :column="2">
        <a-descriptions-item label="单据时间">{{ options.bill_date }}</a-descriptions-item>
        <a-descriptions-item label="员工名称">{{ options.related_user_name }}</a-descriptions-item>
        <a-descriptions-item label="制单时间">{{ options.create_time }}</a-descriptions-item>
        <a-descriptions-item label="制单人">{{ options?.dealerName }}</a-descriptions-item>
      </a-descriptions>
    </a-card>
    <a-card class="smart-margin-top10" size="small" :tab-list="tabList" :active-tab-key="activeKey" @tabChange="(key) => (activeKey = key)">
      <template #customTab="{ tab }">
        <span class="ant-card-head-title" :style="compactModeClass">
          {{ tab }}
        </span>
      </template>
      <template v-if="activeKey === 'store'">
        <CostInventoryTable :enterpriseId="options.details" />
      </template>
      <!-- <template v-if="activeKey === 'log'">
        <CostTracerTimeline :tableData="options.relatedLog" />
      </template> -->
    </a-card>
    <template #footer>
      <a-button @click="onClose">取消</a-button>
    </template>
  </a-drawer>
</template>

<script setup lang="ts">
import CostInventoryTable from './cost-Inventory-table.vue'
// import CostTracerTimeline from './cost-tracer-timeline.vue'
import { useEnums } from '@/hooks/plugins/useEnums'
const compactModeClass = inject('compactModeClass')
const { getDescByValue } = useEnums()
defineExpose({
  showDrawer
})
const emit = defineEmits(['refresh'])

// --------------------- Drawer 显示与隐藏 ---------------------
// 是否展示
const visible = ref(false)
// 详情
const options = ref({})
// 详情tab
const activeKey = ref('store')
const tabList = [
  {
    key: 'store',
    tab: '费用信息'
  }
  // {
  //   key: 'log',
  //   tab: '日志记录'
  // }
]

function showDrawer(item) {
  options.value = item
  visible.value = true
}

const onClose = () => {
  visible.value = false
}
</script>
